package study.datastructure.order.recursion;/**
 * @program: datastructure
 * @author: lcy
 * @create: 2024-09-26 16:01
 */

/**
 2024/9/26,
 */


public class InsertionSort {

    public static void sort(int []a){
        insertion(a,1);
    }
    private static void insertion(int []a, int low){
        if (low==a.length) {
            return;
        }
        int i=low-1;
        int t=a[low];

        while (i>=0&& t<a[i]){
            a[i+1]=a[i]; //右移 空出合适的位置
            i--;
        }
        a[i+1]=t;

        insertion(a,low+1);
    }


}
